#include <QApplication>
#include <QMutex>
#include <QFile>
#include <Configuration.h>
#include <Constants.h>
#include "Resources.h"

namespace Domy {

Resources::Resources()
{

}

Resources::~Resources()
{

}

Resources *Resources::getInstance()
{
    static Resources *s_instance = Q_NULLPTR;
    static QMutex s_mutex;
    QMutexLocker locker(&s_mutex);
    if (!s_instance) {
        s_instance = new Resources();
    }
    return s_instance;
}

QIcon Resources::getIcon(const QString &name) const
{
    return QIcon(QString(":/icon/%2").arg(name));
}

void Resources::loadStyleSheet()
{
    QFile file(":/css/domyxml.css");
    if (file.open(QIODevice::ReadOnly)) {
        QString qss = qApp->styleSheet();
        qApp->setStyleSheet(file.readAll() + qss);
        file.close();
    }
}

} // namespace Domy
